<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta name="renderer" content="webkit">
    <meta content="歪秀购物, 购物, 大家电, 手机" name="keywords">
    <meta content="歪秀购物，购物商城。" name="description">
    <title>浏览记录</title>
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/myFile/imgold/icon/favicon.ico}">
    <link rel="stylesheet" type="text/css" th:href="@{/theme/css/base.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/theme/css/member.css}">

    <link rel="stylesheet" type="text/css" th:href="@{/theme/css/home.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}">
    <script type="text/javascript" th:src="@{/theme/js/jquery.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/delCartOnPages.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/searchToPage.js}"></script>
    <script type="text/javascript" th:src="@{/theme/js/paging.js}"></script>
    <script th:src="@{/layui/layui.all.js}"></script>
    <script type="text/javascript">


        function logout() {
            $.ajax({
                url: "/user/logout",
                dataType: "json",
                data: {},
                async: false,
                success: function (data) {
                    if (data["result"] == "ok") {
                        layer.msg('退出成功', {time: 1000}, function () {
                            window.location = "index";
                        });
                    } else if (data["result"] == "fail") {
                        layer.msg('您还没有登录哦~', {time: 1000}, function () {
                            window.location.reload();
                        });
                    }
                },
                type: "post"
            });
        }

          $(document).ready(function () {
              var data = $("#cartIdNull").val();
            $("#test").mouseover(function () {
                if(data=='notNull'){
                    layer.open({
                        type: 2,
                        title: '我的购物车',
                        shadeClose: true,
                        area: ['19%','60%'],
                        offset: ['9%', '76%'],
                        content: '/cart?pageNum=1&pageSize=100', //iframe的url
                    });
                }else{
                    layer.open({
                        type: 2,
                        title: '我的购物车',
                        shadeClose: true,
                        area: ['20%','20%'],
                        offset: ['9%', '76%'],
                        content: '/cart?pageNum=1&pageSize=100', //iframe的url
                    });
                }
            });

        });

        (function (a) {
            a.fn.hoverClass = function (b) {
                var a = this;
                a.each(function (c) {
                    a.eq(c).hover(function () {
                        $(this).addClass(b)
                    }, function () {
                        $(this).removeClass(b)
                    })
                });
                return a
            };
        })(jQuery);

        $(function () {
            $("#pc-nav").hoverClass("current");
        });

        function del(id) {
            console.log(id);
            layer.confirm('确定要删除吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "/ViewHistory/delViewHistory",
                    dataType: "json",
                    data: {"viewHistoryId": id},
                    async: false,
                    success: function (data) {
                        if (data["result"] == "ok") {
                            layer.msg('删除成功', {time: 1000}, function () {
                                window.location.reload();
                            });
                        } else if (data["result"] == "fail") {
                            layer.msg('删除失败', {time: 1000}, function () {
                                window.location.reload();
                            });
                        } else if (data["result"] == "noSession") {
                            layer.msg('登录失效，请重新登录', {time: 1000}, function () {
                                window.location = "login";
                            });
                        } else {
                            layer.msg('系统错误', {time: 1000}, function () {
                                window.location.reload();
                            });
                        }
                    },
                    type: "post"
                });
            }, function () {
                layer.msg('已取消', {time: 1000});
            });
        }

        function addToCart(commodityId) {



            $.ajax({
                url: "/cart/addToCart",
                dataType: "json",
                data: {
                    "commodityId": commodityId,
                    "specificationId": -1,
                    "commodityCount": -1
                },
                async: false,
                success: function (data) {
                    if (data["result"] == "ok") {
                        layer.msg('添加成功', {time: 1000}, function () {
                            window.location.reload();
                        });
                    } else if (data["result"] == "fail") {
                        layer.msg('添加失败', {time: 1000}, function () {
                            window.location.reload();
                        });
                    } else if (data["result"] == "noSession") {
                        layer.msg('登录失效，请重新登录', {time: 1000}, function () {
                            window.location = "login";
                        });
                    } else if (data["result"] == "exit") {
                        layer.msg('添加成功,购物车数量+' + data["addCount"], {time: 1000}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg('系统错误', {time: 1000}, function () {
                            window.location.reload();
                        });
                    }
                },
                type: "post"
            });

        }

        function delChecked() {
            var allCheckId = "";
            var viewHistorysId = document.getElementsByName("vhc");
            var arrayi = 0;
            var isChecked = false;
            for (var i = 0; i < viewHistorysId.length; i++) {
                if (viewHistorysId[i].checked) {
                    isChecked = true;
                    allCheckId = allCheckId + viewHistorysId[i].id + ",";
                    arrayi++;
                }
            }
            allCheckId = allCheckId.substring(0, allCheckId.length - 1);
            if (isChecked) {
                console.log(allCheckId);
                layer.confirm('确定要删除所选记录吗？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: "/ViewHistory/delCheckedViewHistory",
                        dataType: "json",
                        data: {"allCheckId": allCheckId},
                        async: false,
                        success: function (data) {
                            if (data["result"] == "ok") {
                                layer.msg('删除成功', {time: 1000}, function () {
                                    window.location.reload();
                                });
                            } else if (data["result"] == "fail") {
                                layer.msg('删除失败', {time: 1000}, function () {
                                    window.location.reload();
                                });
                            } else if (data["result"] == "noSession") {
                                layer.msg('登录失效，请重新登录', {time: 1000}, function () {
                                    window.location = "login";
                                });
                            } else if (data["result"] == "isNull") {
                                layer.msg('您还未做任何选择', {time: 1000}, function () {
                                    window.location = "login";
                                });
                            } else {
                                layer.msg('系统错误', {time: 1000}, function () {
                                    window.location.reload();
                                });
                            }
                        },
                        type: "post"
                    });
                }, function () {
                    layer.msg('已取消', {time: 1000});
                });
            } else {
                layer.msg('您还未做任何选择', {time: 1000}, function () {
                });
            }
        }

        function checkAll(check) {
            var viewHistorysId = document.getElementsByName("vhc");
            if (check.checked) {
                for (var i = 0; i < viewHistorysId.length; i++) {
                    viewHistorysId[i].checked = true;
                }
            } else {
                for (var i = 0; i < viewHistorysId.length; i++) {
                    viewHistorysId[i].checked = false;
                }
            }
        }
    </script>

    <script>

        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage
                , layer = layui.layer;

            });

        });
    </script>
</head>

<body>
<input type="hidden" id="cartIdNull" th:value="${session.cartIsNull}">
<header id="pc-header">
    <div class="BHeader">
        <div class="yNavIndex">
            <ul class="BHeaderl">
                <li><a th:if="${session.userId}==null" th:href="@{/login}">请登录</a></li>
                <li class="headerul" th:if="${session.userId}==null">|</li>
                <li><a th:if="${session.userId}==null" th:href="@{/register}">免费注册</a></li>
                <li class="headerul" th:if="${session.userId}==null">|</li>
                <li><a th:href="@{/myOrder?pageNum=1&pageSize=5}" th:if="${session.userId}!=null">我的订单</a></li>
                <li class="headerul" th:if="${session.userId}!=null">|</li>
                <li><a th:href="@{/myCollect?pageNum=1&pageSize=8}" th:if="${session.userId}!=null">我的收藏</a></li>
                <li class="headerul" th:if="${session.userId}!=null">|</li>
                <li id="pc-nav" class="menu" th:if="${session.userId}!=null"><a th:href="@{#}" class="tit">我的淘淘</a>
                    <div class="subnav">
                        <a th:href="@{/accountSecurity}">账户安全</a>
                        <a th:href="@{/myAddress}">地址管理</a>
                        <a th:href="@{/myEvaluate?pageNum=1&pageSize=5}">我的评价</a>
                        <a th:href="@{/viewHistory?pageNum=1&pageSize=5}">浏览记录</a>
                    </div>
                </li>
                <li class="headerul" th:if="${session.userId}!=null">|</li>
                <li th:if="${session.userId}!=null">
                    <a th:text="${session.userName}"></a>
                </li>
                <li th:if="${session.userId}!=null">
                    <img th:src="'/myFile/img/userHeadPic/'+${session.userHead}+''"
                         onclick="javascript:window.location='myInfo'" style=" width:30px;height:30px;">
                    <a href="javascript:logout()" style="float: right;">退出</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="container clearfix" style="padding:20px 0 20px ">
        <div class="header-logo fl"><h1><a th:href="@{/index}" style="color:#ea4949;">
            <img th:src="@{/myFile/imgold/icon/logo1.png}" style="width:100px;height:80px;"><strong>淘淘商城</strong></a>
        </h1>
        </div>
        <div class="head-form fl">
            <form class="clearfix">
                <input type="text" class="search-text" id="searchKey" autocomplete="off" placeholder="手机">
                <button type="button" class="button" onclick="searchToPage();">搜索</button>
            </form>
            <div class="words-text clearfix">
                <a th:href="@{#}" class="red">1元秒爆</a>
                <a th:href="@{#}">低至五折</a>
                <a th:href="@{#}">农用物资</a>
                <a th:href="@{#}">买一赠一</a>
                <a th:href="@{#}">佳能相机</a>
                <a th:href="@{#}">稻香村月饼</a>
                <a th:href="@{#}">服装城</a>
            </div>
        </div>
        <div class="header-cart fr" th:if="${session.userId}!=null">
            <a  th:href="@{/myCart?pageNum=1&pageSize=5}" target="_blank"
                style="height:30px;width:30px;float:right;margin-right:50px;"><img
                    id="test" src="../myFile/imgold/icon/car.png"></a>
            <i th:if="${session.cartIsNull}=='notNull'" class="head-amount" id="cartCountExist" th:text="${session.cartAllCount}"></i>
            <i th:if="${session.cartIsNull}=='null'" class="head-amount" id="cartCountUnExist">0</i>
        </div>
    </div>
</header>

<div class="containers">
    <div class="pc-nav-item"><a th:href="@{/index}">首页</a> &gt; <a th:href="@{#}">会员中心 </a> &gt; <a
            th:href="@{#}">商城快讯</a></div>
</div>

<section id="member">
    <div class="member-center clearfix">
        <div class="member-left fl">
            <div class="member-apart clearfix">
                <div class="fl"><a th:href="@{#}"><img th:src="'/myFile/img/userHeadPic/'+${session.userHead}+''"
                                                       onclick="javascript:window.location='myInfo'"></a></div>
                <div class="fl">
                    <p>昵称：</p>
                    <p><a th:href="@{/#}" th:text="${session.userName}"></a></p>
                </div>
            </div>
            <div class="member-lists">
                <dl>
                    <dt>我的淘淘</dt>
                    <dd><a th:href="@{/myOrder?pageNum=1&pageSize=5}">我的订单</a></dd>
                    <dd><a th:href="@{/myCollect?pageNum=1&pageSize=8}">我的收藏</a></dd>
                    <dd><a th:href="@{/accountSecurity}">账户安全</a></dd>
                    <dd><a th:href="@{/myEvaluate?pageNum=1&pageSize=5}">我的评价</a></dd>
                    <dd><a th:href="@{/myAddress}">地址管理</a></dd>
                    <dd class="cur"><a th:href="@{/viewHistory?pageNum=1&pageSize=5}">浏览记录</a></dd>
                </dl>
                <dl>
                    <dt>客户服务</dt>

                     <dd><a th:href="@{/request}">退货/退款记录</a></dd>
                </dl>
                <dl>
                    <dt>我的消息</dt>
                    <dd><a th:href="@{#}">商城快讯</a></dd>
                    <dd><a th:href="@{#}">帮助中心</a></dd>
                </dl>
            </div>
        </div>
        <div class="member-right fr">
            <div class="member-head" style="background: #fff;">
                <div class="member-heels fl"><h2 style="color:black"><strong>浏览记录</strong></h2></div>
                <div class="member-heels fr">
                    <button class="layui-btn layui-btn-primary" style="float:right" onclick="delChecked()">删除选中</button>
                </div>
            </div>
            <table class="layui-table" lay-skin="line" style="-width:970px;padding:10px;"th:if="${commodityViewHistorys}!='noView'">
                <colgroup>
                    <col width="80">
                    <col width="100">
                    <col width="250">
                    <col width="140">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th><input type="checkbox" id="checkOrCancelAll" onclick="checkAll(this)"><label
                            for="checkOrCancelAll">全选</label>
                    <th>商品图片</th>
                    <th>商品名称</th>
                    <th>单价</th>
                    <th>浏览时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="vhtbody">
                <tr th:each='cvs : ${commodityViewHistorys}'>
                    <td>
                        <input type="checkbox" name="vhc" th:id="${cvs.viewHistoryid}">
                    </td>
                    <td>
                        <a th:href="'/commodityInfo?commodityId='+${cvs.commodityId}+''">

                            <img th:src="'/myFile/img/commodityPic/'+${cvs.comPicture}+''"
                                 width="90" height="90">
                        </a>
                    </td>

                    <td>
                        <a th:href="'/commodityInfo?commodityId='+${cvs.commodityId}+''" style="margin-top:-60px;">
                            <span th:text="${cvs.name}"></span>
                        </a>
                    </td>
                    <td>
                        <span>￥</span><span th:text="${cvs.comPrice}"></span>
                    </td>
                    <td>
                        <span th:text="${cvs.viewTime}"></span>
                    </td>
                    <td>
                        <button class="layui-btn layui-btn-sm layui-btn-primary"
                                th:onclick="'javascript:del('+${cvs.viewHistoryid}+')' ">删除
                        </button>
                        <button class="layui-btn layui-btn-sm" style="background:#ea4949;"
                                th:onclick="'javascript:addToCart('+${cvs.commodityId}+')' ">
                            加入购物车
                        </button>
                    </td>
                </tr>

                </tbody>
            </table>
            <div class="member-troll clearfix"style="border-bottom: none"th:if="${commodityViewHistorys}!='noView'">
                <div class="member-check clearfix fr">
                    <a th:href="'javascript:upPage(\'viewHistory?'+'\','+${pageNum}+','+${pageSize}+')'"style="background:url(/myFile/imgold/icon/s-a3.png) no-repeat left;color:#ea4949;width:60px;height:26px">上一页</a>
                    <span class="pc-search-t"><input type="text" style="width:50px;height:22px"id="inputpageNum" th:value="${pageNum}"><em>&nbsp/</em><i th:text="${viewPageCount}"></i></span>
                    <a th:href="'javascript:toPage(\'viewHistory?'+'\','+${pageNum}+','+${pageSize}+','+${viewPageCount}+',\'inputpageNum\')'"style="color:#005aa0;background:#fff;border:1px solid #cccccc;width:60px;height:26px;">go</a>
                    <a th:href="'javascript:nextPage(\'viewHistory?'+'\','+${pageNum}+','+${pageSize}+','+${viewPageCount}+')'"style="background:url(/myFile/imgold/icon/s-a1.png) no-repeat right;color:#ea4949;width:60px;height:26px">下一页</a>
                </div>
            </div>
            <div th:if="${commodityViewHistorys}=='noView'">
                <div style="text-align: center;font-size: 18px;margin:0 20px 40px 20px;">您还没有浏览过任何商品呢~</div>
            </div>
        </div>
    </div>
</section>

<div class="aui-footer-bot">
    <div class="time-lists aui-footer-pd clearfix">
        <div class="aui-footer-list clearfix">
            <h4>
                <span><img th:src="@{/myFile/imgold/icon/icon-d1.png}"></span>
                <em>消费者权益</em>
            </h4>
            <ul>
                <li><a th:href="@{#}">保障范围 </a></li>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>
                <span><img th:src="@{/myFile/imgold/icon/icon-d2.png}"></span>
                <em>新手上路</em>
            </h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>
                <span><img th:src="@{/myFile/imgold/icon/icon-d3.png}"></span>
                <em>保障正品</em>
            </h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>
                <span><img th:src="@{/myFile/imgold/icon/icon-d1.png}"></span>
                <em>消费者权益</em>
            </h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
    </div>
    <div style="border-bottom:1px solid #dedede"></div>
    <div class="time-lists aui-footer-pd time-lists-ls clearfix">
        <div class="aui-footer-list clearfix">
            <h4>购物指南</h4>
            <ul>
                <li><a th:href="@{#}">保障范围 </a></li>
                <li><a th:href="@{#}">购物流程</a></li>
                <li><a th:href="@{#}">会员介绍 </a></li>
                <li><a th:href="@{#}">生活旅行</a></li>
                <li><a th:href="@{#}"> 常见问题 </a></li>
                <li><a th:href="@{#}"> 联系客服购物指南 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>特色服务</h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>帮助中心</h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
        <div class="aui-footer-list clearfix">
            <h4>新手指导</h4>
            <ul>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">退货退款流程</a></li>
                <li><a th:href="@{#}">服务中心 </a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}">服务中心</a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
                <li><a th:href="@{#}"> 更多特色服务 </a></li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>